package com.tourism.controller;

import com.github.pagehelper.PageInfo;
import com.tourism.entity.AttractionOrder;
import com.tourism.entity.AttractionOrderQuery;
import com.tourism.entity.OrderPayInfo;
import com.tourism.service.AttractionOrderService;
import com.tourism.util.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 景点订单相关的控制器
 * @Author z
 * @Date 2021-03-01 20:40
 */
@Controller
@RequestMapping("/attractionOrder")
public class AttractionOrderController {


    @Autowired
    private AttractionOrderService attractionOrderService;

    /**
     * 根据景点订单id查询景点订单信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getAttractionOrderById")
    @ResponseBody
    public AttractionOrder getAttractionOrderById(Long id) {
        return attractionOrderService.getAttractionOrderById(id);
    }

    /**
     * 删除景点订单
     *
     * @param id
     * @return
     */
    @DeleteMapping("/deleteAttractionOrderById")
    @ResponseBody
    public Response deleteAttractionOrderById(Long id) {
        return Response.success(attractionOrderService.deleteAttractionOrderById(id));

    }

    /**
     * 新增景点订单
     *
     * @param attractionOrder
     * @return
     */
    @PostMapping("/addAttractionOrder")
    @ResponseBody
    public Response addAttraction(@RequestBody AttractionOrder attractionOrder) {

        return Response.success(attractionOrderService.addAttractionOrder(attractionOrder));

    }

    /**
     * 支付景点订单
     *
     * @param orderPayInfo
     * @return
     */
    @PostMapping("/updateOrderPayInfo")
    @ResponseBody
    public Response updateOrderPayInfo(@RequestBody OrderPayInfo orderPayInfo) {

        return Response.success(attractionOrderService.updateOrderPayInfo(orderPayInfo));

    }


    /**
     * 查询景点订单列表
     *
     * @param attractionOrderQuery
     * @return
     */
    @PostMapping("/getAttractionOrderList")
    @ResponseBody
    public PageInfo<AttractionOrder> getAttractionOrderList(@RequestBody AttractionOrderQuery attractionOrderQuery) {
        return attractionOrderService.getAttractionOrderList(attractionOrderQuery);
    }

}
